﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using SpringWaterDataAccess;
using admin;

namespace sow
{
	/// <summary>
	/// Summary description for admin01.
	/// </summary>
	public partial class admin01 : System.Web.UI.Page
	{
	
		protected void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here

			if (!IsPostBack) 
			{
				SQLAccess sql = new SQLAccess();
				DataSet partners = sql.getAllPartners();

				SourceList.DataSource = partners;
				SourceList.DataTextField = "PartnerCode";
				SourceList.DataValueField = "PartnerID";
				SourceList.DataBind();

				DataSet Categories = sql.getAllCategories();

				CategoryList.DataSource = Categories;
				CategoryList.DataTextField = "CategoryCode";
				CategoryList.DataValueField = "CategoryID";
				CategoryList.DataBind();
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    

		}
		#endregion

		
		private void Select1_ServerChange(object sender, System.EventArgs e)
		{
		
		}

		protected void Submit1_ServerClick(object sender, System.EventArgs e)
		{
			UserObject.AddWord(
					TextTitle.Text, 
					Convert.ToInt32(CategoryList.SelectedItem.Value),
					Convert.ToInt32(SourceList.SelectedItem.Value), 
					TextAuthor.Text, 
					"", //description
					TextLocation.Text, 
					2, // User ID 
					TextRecommendBy.Text,
				    DateTime.Parse(TextPubDate.Text)); 			
		}

		protected void TextTitle_TextChanged(object sender, System.EventArgs e)
		{
		
		}

		protected void TextAuthor_TextChanged(object sender, System.EventArgs e)
		{
		
		}

		protected void SourceList_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}

		protected void CategoryList_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}
			
		}
}
